package cn.livingCloud.service.impl.operation;

import cn.livingCloud.dto.front.CaseAccusationFrontFromDto;
import cn.livingCloud.entity.core.Case;

/**
 * Created by 唐旭 on 2016/6/13.
 */
public class CaseAccusationFrontFromDtoUpdator extends CaseFormDtoUpdater {
    private CaseAccusationFrontFromDto formDto;

    public CaseAccusationFrontFromDtoUpdator(CaseAccusationFrontFromDto formDto) {
        super(formDto);
        this.formDto = formDto;
    }

    public String updateFront() {
        String uuid = createCase();
        createCasesImage(uuid);
        return uuid;
    }

    @Override
    protected String createCase() {
        Case aCase = new Case();
        aCase.setAddressDescription(formDto.getAddressDescription())
                .setPhone(formDto.getPhone())
                .setLocationX(formDto.getLocationX())
                .setLocationY(formDto.getLocationY()).setCreatorUuid(formDto.getCreatorUuid());
        aCase.setCaseCategoryUuid(formDto.getCaseCategoryUuid());
        mapper.insert(aCase);
        return aCase.getUuid();
    }
}
